<?php

namespace app\api\controller;

use Tencent\TLSSigAPIv2;

class Tencent extends Common
{
    public function userSig($appid = '')
    {
        $TLS_APPID = getenv('TLS_APPID');
        $TLS_KEY = getenv('TLS_KEY');
        $appid = $appid ? $appid : $TLS_APPID;
        if ($appid != $TLS_APPID) {
            $TLS_APPID = getenv('RELANG_TLS_APPID');
            $TLS_KEY = getenv('RELANG_TLS_KEY');
        }
        $api = new TLSSigAPIv2($TLS_APPID, $TLS_KEY);
        $sig = $api->genSig($this->member['id']);

        return $this->pass(['userSig' => $sig]);
    }
    public function userSig2()
    {
       $user_id = input('user_id',0);
        if (!$user_id){
            $user_id = $this->member['id'];
        }
        $TLS_APPID = getenv('TLS_IM_APPID');
        $TLS_KEY = getenv('TLS_IM_KEY');
        $api = new TLSSigAPIv2($TLS_APPID, $TLS_KEY);
        // $sig = $api->genSig($this->member['id']);
        $sig = $api->genSig($user_id);
        return $this->pass(['userSig' => $sig]);
    }
}
